Example #1
0
        /*++
         * 
         * Read Lock Section
         * 
         --*/

        //
        // Tries to enter the read lock if this is the first reader
        // or a recursive acquisition.
        //

        private bool FastTryEnterRead(int tid, out OwnerEntry oce) {
            oce = null;

            //
            // Try to enter the read lock as the first reader.
            //

            if (rwlock.state == 0 &&
                Interlocked.CompareExchange(ref rwlock.state, 1, 0) == 0) {
                firstReader = tid;
                firstReaderCount = 1;
                return true;
            }

            //
            // Check if this is a recursive acquisition and the current
            // thread is the first reader.
            //

            if (firstReader == tid) {
                firstReaderCount++;
                return true;
            }

            //
            // Check if the current thread is already a read lock owner.
            //

            if (readOwner.LookupEntry(tid, out oce)) {
                oce.count++;
                return true;
            }
            return false;
        }
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            await Task.Delay(200);

            OwnerEntry.Focus();
        }
Example #3
0
        /// <summary>
        /// Adds an owner to a group.
        /// </summary>
        /// <param name="ownerEmail">Email of the owner that is being added to the group</param>
        /// <param name="groupId">The group to which the member is being added</param>
        /// <returns>a <code>OwnerEntry</code> containing the results of the
        /// creation</returns>
        public OwnerEntry AddOwnerToGroup(String ownerEmail, String groupId)
        {
            String requestUri = String.Format("{0}/{1}/{2}/{3}",
                                              AppsGroupsNameTable.AppsGoogleGroupsBaseFeedUri,
                                              domain,
                                              groupId,
                                              AppsGroupsNameTable.owner);

            OwnerEntry entry = new OwnerEntry();

            entry.Email = ownerEmail;

            return(Insert(requestUri, entry));
        }
Example #4
0
            //
            // Looks up for an entry belonging to the specified thread id.
            //

            internal bool LookupEntry(int tid, out OwnerEntry entry) {
                int hi = tid & HASH_TABLE_MASK;
                entry = null;
                OwnerEntry p = table[hi].tail;
                while (p != null) {
                    if (tid == p.key) {
                        entry = p;
                        return true;
                    }
                    if (entry == null && p.key == OwnerEntry.FREE_ENTRY) {
                        entry = p;
                    }
                    p = p.next;
                }
                return false;
            }
Example #5
0
        /// <summary>
        /// Checks whether an user is a group owner.
        /// </summary>
        /// <param name="ownerEmail">Email of the owner that is being checked</param>
        /// <param name="groupId">The ID of the group for which you wish to check the ownership</param>
        /// <returns>True if the user is an owner of the group, false otherwise</returns>
        public bool IsOwner(String ownerEmail, String groupId)
        {
            try {
                OwnerEntry entry = RetrieveOwner(ownerEmail, groupId);
                return(entry != null);
            } catch (GDataRequestException e) {
                AppsException appsException = AppsException.ParseAppsException(e);
                if (appsException == null)
                {
                    return(false);
                }

                if (appsException.ErrorCode.Equals(AppsException.EntityDoesNotExist))
                {
                    return(false);
                }
                else
                {
                    throw appsException;
                }
            }
        }
Example #6
0
            //
            // Allocates an owner entry for the specified thread id.
            //

            internal OwnerEntry AllocateEntry(int tid, OwnerEntry hint) {
                if (hint != null && hint.CasKey(OwnerEntry.FREE_ENTRY, tid)) {
                    hint.count = 1;
                    return hint;
                }
                int hi = tid & HASH_TABLE_MASK;
                OwnerEntry p = table[hi].tail;
                while (p != null) {
                    if (p.CasKey(OwnerEntry.FREE_ENTRY, tid)) {
                        p.count = 1;
                        return p;
                    }
                    p = p.next;
                }
                OwnerEntry ne = new OwnerEntry(tid);
                do {
                    p = table[hi].tail;
                    ne.next = p;
                    if (table[hi].CasTail(p, ne)) {
                        return ne;
                    }
                } while (true);
            }
Example #7
0
 internal bool CasTail(OwnerEntry t, OwnerEntry nt) {
     return (tail == t &&
             Interlocked.CompareExchange<OwnerEntry>(ref tail, nt, t) == t);
 }